import json

from selenium import webdriver      #导入web端
from Page import Page               #导入Page类——登录
from Page1 import Page1             #导入Page1类——支付下单
import pytest                   #导入pytest方法
import time                     #导入时间

# #使用json数据驱动
# def du(path):
#     with open(path,'r',encoding='utf-8')as f:
#         data = json.load(f)
#         return data


@pytest.fixture(scope='function')
def driver():
    driver = webdriver.Edge()             #获取edge浏览器
    driver.maximize_window()              #放大屏幕
    yield driver
    time.sleep(10)
    driver.quit()
#调用登录业务
# @pytest.mark.parametrize('data',du(r'E:\gaoer\rk\pythonProject\ZK3\a3mall.json'))
def test_01_login(driver):
    po = Page(driver)
    po.luoji_A3mall()
#调用商品模块——对商品支付下单
def test_02_xiadan(driver):
    po = Page(driver)
    po.luoji_A3mall()
    po = Page1(driver)
    time.sleep(2)
    po.shouye()     #点击首页
    time.sleep(2)
    po.shuruk()     #输入框输入商品名称
    time.sleep(2)
    po.search()     #点击搜索按钮
    time.sleep(2)
    po.sp()         #点击商品定位
    time.sleep(2)
    po.ljgm()       #点击立即购买
    time.sleep(2)
    po.dizhi()      #点击收货地址
    time.sleep(2)
    po.zhifu()      #选择支付方式
    po.screenshoot('a3mall.png')
    time.sleep(2)
    po.xyb()        #点击下一步
    driver.implicitly_wait(5)






# class TestCase():
    # @pytest.fixture(scope="session", autouse=True)
# @pytest.fixture(scope='function')
# def driver(self):
#     self.driver = webdriver.Edge()      #获取edge浏览器
#     self.driver.maximize_window()       #屏幕放大
#     yield self.driver                   #将浏览器数据放入driver里
#     time.sleep(10)                      #等待10秒
#     self.driver.quit()                  #退出浏览器




# #调用登录业务
# def test_01_login(self):
#     po = Page(self.driver)
#     po.luoji_A3mall()



if __name__ == '__main__':
    pytest.main()
